home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / txf / src / txfswchk.c < prev   
C/C++ Source or Header  |  1993-07-08  |  4KB  |  238 lines

  1. /***************
  2. *
  3. * g:\exe\txf\src\txfswchk.c
  4. */
  5. #include "txf.h"
  6.  
  7. char *tkl, *tkf, *tkq;
  8. void case_k(char c, char *str)
  9. {
  10.     if (c == 'f')
  11.         kf = ktrans(str);
  12.     if (c == 'l')
  13.         kl=ktrans(str);
  14.     if (c =='q')
  15.         kq = ktrans(str);
  16.     tkl = kl;
  17.     tkf = kf;
  18.     tkq = kq;
  19. }
  20.  
  21. void case_r(char c)
  22. {
  23.     if (c == NUL) {
  24.         retflg = 1;
  25.     }
  26.     else if (c == 'z') {
  27.         removeeofflg = 1;
  28.     }
  29.     else if (c =='b') {
  30.         removebakfile = 1;
  31.     }
  32. }
  33.  
  34. void case_e(char c)
  35. {
  36.     if (c == 'x') format = 0;
  37. #if !TXFL
  38.     if (c == 'p') useoldex = 0;
  39.     if (c == 's') useoldex = 1;
  40. #endif
  41. }
  42.  
  43. void swchk(int count, char **val)
  44. {
  45.     int i;
  46.  
  47.     for (i = 0; val[i] != NULL; i++) {
  48.         if (val[i][0] == '-') {
  49.             val[i][1] = tolower(val[i][1]);
  50.             val[i][2] = tolower(val[i][2]);
  51.             switch(val[i][1]) {
  52.             case 'i':
  53.                 if (val[i][2] == NUL) {
  54.                     if ((val[i+1][0] != '-') && (val[i+1][0] != '@')) {
  55.                         strcpy(inputfile, val[i+1]);
  56.                         gftime(inputfile, ftime);
  57.                     }
  58.                     else {
  59.                         i--;
  60.                     }
  61.                 }
  62.                 if (val[i][2] == 'o') {
  63.                     strcpy(wcfile, val[i+1]);
  64.                 }
  65.                 break;
  66.             case 'o':
  67.                 if ((val[i+1][0] != '-') && (val[i+1][0] != '@')) {
  68.                     strcpy(outputfile, val[i+1]);
  69.                 }
  70.                 else {
  71.                     i--;
  72.                 }
  73.                 break;
  74.             case 'c':
  75.                 if ((val[i+1][0] != '-') && (val[i+1][0] != '@')) {
  76.                     cent = atoi(val[i+1]);
  77.                 }
  78.                 else {
  79.                     cent = 60;
  80.                     i--;
  81.                 }
  82.                 break;
  83.             case 'l':
  84.                 if (strlen(val[i]) == 2) {
  85.                     if ((val[i+1][0] != '-') && (val[i+1][0] != '@')) {
  86.                         maxc = atoi(val[i+1]);
  87.                     }
  88.                     else {
  89.                         i--;
  90.                     }
  91.                 }
  92.                 else if (val[i][2] == 'c') {
  93.                     lcxdriver(&val[i+1]);
  94.                 }
  95. #if !TXFL
  96.                 else if (val[i][2] == 'o') {
  97.                     logdriver(&val[i+1]);
  98.                 }
  99. #endif
  100.                 break;
  101.             case 'b':
  102.                 if ((val[i+1][0] != '-') && (val[i+1][0] != '@')) {
  103.                     base = atoi(val[i+1]);
  104.                 }
  105.                 else {
  106.                     base = 0;
  107.                     i--;
  108.                 }
  109.                 break;
  110.             case 'm':
  111.                 if ((val[i][2] == 'r') && (val[i+1][0] != '-') &&
  112.                     (val[i+1][0] != '@')) {
  113.                     right = atoi(val[i+1]);
  114.                 }
  115.                 else if ((val[i][2] == 'l') && (val[i+1][0] != '-') &&
  116.                     (val[i+1][0] != '@')) {
  117.                     left = atoi(val[i+1]);
  118.                 }
  119.                 else {
  120.                     i--;
  121.                 }
  122.                 break;
  123.             case 'k':
  124.                 case_k(val[i][2], val[i+1]);
  125.                 break;
  126.             case 's':
  127.                 sep = val[i+1][0];
  128.                 break;
  129.             case 't':
  130.                 if (val[i+1][0] != '-' && val[i+1][0] != '@') {
  131.                     tabsize = atoi(val[i+1]);
  132.                 }
  133.                 else {
  134.                     i--;
  135.                 }
  136.                 break;
  137.             case 'v':
  138.                 viewmode = 1;
  139.                 if (val[i][2] != NUL) {
  140.                     viewmode = atoi(&val[i][2]);
  141.                     i--;
  142.                 }
  143.                 else {
  144.                     if ((val[i+1][0] != '-') && (val[i+1][0] != '@')
  145.                         && (val[i+1][0] != NUL)) {
  146.                         viewmode = atoi(val[i+1]);
  147.                     }
  148.                     else {
  149.                         i--;
  150.                     }
  151.                 }
  152.                 break;
  153.             case 'r':
  154.                 case_r(val[i][2]);
  155.                 i--;
  156.                 break;
  157.             case 'n':
  158.                 if (val[i][2] == NUL) {
  159.                     format = 0;
  160.                     i--;
  161.                 }
  162. #if !TXFL
  163.                 else if (val[i][2] == 'p') {
  164.                     npcutdriver(&val[i+1]);
  165.                 }
  166. #endif
  167.                 break;
  168.             case 'f':
  169.                 format = 1;
  170.                 i--;
  171.                 break;
  172.             case 'x':
  173.                 tabx = 1;
  174.                 i--;
  175.                 break;
  176.             case 'q':
  177.                 quoteflg = 1;
  178.                 i--;
  179.                 break;
  180.             case 'a':
  181.                 init_allswitch();
  182.                 i--;
  183.                 break;
  184.             case 'p':
  185.                 setline = 2;
  186.                 i--;
  187.                 break;
  188.             case 'd':
  189.                 if (val[i][2] == NUL) {
  190.                     if ((val[i+1][0] != '-') && (val[i+1][0] != '@') &&
  191.                         (val[i+1][0] != NUL)) {
  192.                         strncpy(tfile[0], val[i+1], 64);
  193.                     }
  194.                     else{
  195.                         i--;
  196.                     }
  197.                 }
  198.                 break;
  199.             case 'e':
  200.                 if (val[i][2] == NUL) {
  201.                     if (exflg > EX_MAX) errexit("too many exchange block");
  202.                     exold[exflg] = &val[i+1][0];
  203.                     if ((val[i+2][0] != '-') && (val[i+2][0] != '@')) {
  204.                         exnew[exflg] = val[i+2];
  205.                         i++;
  206.                     }
  207.                     exflg += 1;
  208.                 }
  209.                 else {
  210.                     case_e(val[i][2]);
  211.                 }
  212.                 break;
  213. #if !NOHELP
  214.             case '?':
  215.             case 'h':
  216.                 credit(basedir);
  217. #endif
  218.             default:
  219.                 fprintf(stderr, "Error:invailed parameter'%s'\n", val[i]);
  220. #if !NOHELP
  221.                 credit(basedir);
  222. #endif
  223.                 /* exit(1); */
  224.             }
  225.             i++;
  226.         }
  227.         else if (val[i][0] == '@') {
  228.             read_commandfile(&val[i][1]);
  229.         }
  230.         else if (*inputfile == NUL) {
  231.             strcpy(inputfile, val[i]);
  232.         }
  233.     }
  234.     kl=tkl;
  235.     kf=tkf;
  236.     kq=tkq;
  237. }
  238.